﻿<%@ Page Title="" Language="C#" AutoEventWireup="true" MasterPageFile="~/Main.Master" CodeBehind="Price.aspx.cs" Inherits="DevExpressWebApplication1.Module.CM.Price" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script>
        function openAdd() {
            popupAddEdit.Show();
        }
        function isCopy(bool) {
            if (bool)
                $('#trPriceGroup').show();
            else
                $('#trPriceGroup').hide();
        }
        function SaveComplete(s, e) {

            if (e.result != "") {
                var check = e.result;
                if (check == "Success") {
                    ClearData();
                    popupAddEdit.Hide();
                    gvProduct.PerformCallback();
                    alert("Thành công");
                } else if (check == "SuccessAndNew") {
                    New();
                }
                else {
                    alert("Thất bại");
                }
            }
        }
    </script>
    <div class="span10">
        <dx:ASPxButton runat="server" ID="btnAdd" Text="Add" Theme="DevEx" UseSubmitBehavior="False" AutoPostBack="False">
            <ClientSideEvents Click="function(s,e){openAdd()}" />
        </dx:ASPxButton>
    </div>
    <div class="span11">
        <table style="width: 100%; height: 600px;">
            <tr>
                <td style="width:50%">
                    <dx:ASPxGridView runat="server" ID="gvPriceGroup" DataSourceID="dsPriceGroup" Width="100%" ClientInstanceName="gvPriceGroup" AutoGenerateColumns="False" KeyFieldName="price_group_id">
                    </dx:ASPxGridView>
                    <asp:SqlDataSource runat="server" ID="dsPriceGroup" ConnectionString="<%$ ConnectionStrings:PPL_ERPConnectionString %>" 
                        SelectCommand="sp_PriceGroup_GetAll" SelectCommandType="StoredProcedure" />
                </td>
                <td>
                    <dx:ASPxGridView runat="server" ID="gvPrice" Width="100%" ClientIDMode="Static" ClientInstanceName="gvPrice">
                    </dx:ASPxGridView>
                </td>
            </tr>
        </table>
    </div>
    <dx:ASPxPopupControl ID="popupAddEdit" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
        CssPostfix="Aqua" SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" ClientInstanceName="popupAddEdit"
        HeaderText="Quản lý nhóm bảng giá" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Theme="DevEx"
        EnableClientSideAPI="True" Width="400px" Height="200px">
        <%-- PopupElementID="divPotential" --%>
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl6" runat="server" SupportsDisabledAttribute="True">
                <div style="width: 100%">
                    <dx:ASPxCallbackPanel ID="cbAddEdit" ClientInstanceName="cbAddEdit" OnCallback="cbAddEdit_Callback" runat="server" Width="100%">
                        <PanelCollection>
                            <dx:PanelContent>
                                <dx:ASPxHiddenField ID="hdfCustomerID" ClientInstanceName="hdfCustomerID" runat="server" />
                                <table width="100%">
                                    <tr>
                                        <td style="width: 40%">Tên nhóm bảng giá
                                        </td>
                                        <td style="width: 60%">
                                            <dx:ASPxTextBox ID="txtPriceGroupName" ClientInstanceName="txtPriceGroupName" runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 40%">Ghi chú 
                                        </td>
                                        <td style="width: 60%">
                                            <dx:ASPxTextBox ID="txtDescription" ClientInstanceName="txtDescription" runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <dx:ASPxCheckBox runat="server" ID="chkCopy" ClientInstanceName="chkCopy">
                                                <ClientSideEvents CheckedChanged="function(s,e){ isCopy(chkCopy.GetValue()); }" />
                                            </dx:ASPxCheckBox>
                                        </td>
                                    </tr>
                                    <tr id="trPriceGroup" style="display:none">
                                        <td style="width: 40%">
                                            nhóm bảng giá 
                                        </td>
                                        <td style="width: 60%">
                                            <dx:ASPxTextBox ID="txtCompany" ClientInstanceName="txtCompany" runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <dx:ASPxButton ID="ASPxButton1" runat="server" Text="Cập nhật" UseSubmitBehavior="False" AutoPostBack="False">
                                                <ClientSideEvents Click="function(s,e){ cpReloadGrid.PerformCallback(); }" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </div>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>
    <dx:ASPxCallback ID="cpReloadGrid" ClientInstanceName="cpReloadGrid" runat="server"
        OnCallback="cpReloadGrid_Callback">
        <ClientSideEvents CallbackComplete="function(s,e){SaveComplete(s,e);}" />
    </dx:ASPxCallback>
</asp:Content>
